﻿namespace Sai.Core.Reporting
{
	using System.IO;
	using System.Text.RegularExpressions;

	public static class StringExtensions
	{
		public static string ToSafeFileName(this string fileName)
		{
			string expression = string.Format("[{0}]", Regex.Escape(new string(Path.GetInvalidFileNameChars())));
			Regex removeInvalid = new Regex(expression, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);

			return removeInvalid.Replace(fileName, string.Empty);
		}
	}
}
